2020-2021 Sunseeker Telemetry and Lighting System
lcd_b_ex1_4mux.c
Go to the documentation of this file.
1 /* --COPYRIGHT--,BSD
2  * Copyright (c) 2017, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  * --/COPYRIGHT--*/
32 //*****************************************************************************
68 //*****************************************************************************
69 #include "driverlib.h"
70 
71 int main(void) {
72 
73  WDT_A_hold(WDT_A_BASE);
74 
75  //Set P5SEL P5.3/P5.4/P5.5 for LCD_B COM1/COM2/COM3
76  GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_P5,
77  GPIO_PIN3|GPIO_PIN4|GPIO_PIN5);
78 
79  //Unlock Battery Backup subsystem for XT1 operation
80  while(BattBak_unlockBackupSubSystem(BAK_BATT_BASE) == BATTBAK_UNLOCKFAILURE);
81 
82  //Initializes the XT1 crystal oscillator with no timeout
83  //In case of failure, code hangs here.
84  //For time-out instead of code hang use UCS_turnOnLFXT1WithTimeout()
85  UCS_turnOnLFXT1(
86  UCS_XT1_DRIVE_0,
87  UCS_XCAP_3
88  );
89 
90  //Set LCD functions pins from S0 to S11
91  LCD_B_setPinAsLCDFunctionEx(LCD_B_BASE, LCD_B_SEGMENT_LINE_0, LCD_B_SEGMENT_LINE_11);
92 
93  //Initialize LCD
94  LCD_B_initParam initParams = {0};
95  initParams.clockSource = LCD_B_CLOCKSOURCE_ACLK;
96  initParams.clockDivider = LCD_B_CLOCKDIVIDER_1;
97  initParams.clockPrescalar = LCD_B_CLOCKPRESCALAR_16;
98  initParams.muxRate = LCD_B_4_MUX;
99  initParams.segments = LCD_B_SEGMENTS_ENABLED;
100  LCD_B_init(LCD_B_BASE, &initParams);
101 
102  //LCD Operation - VLCD generated internally, V2-V4 generated internally, v5 to ground
103  LCD_B_setVLCDSource(LCD_B_BASE, LCD_B_VLCD_GENERATED_INTERNALLY,
104  LCD_B_V2V3V4_GENERATED_INTERNALLY_NOT_SWITCHED_TO_PINS,
105  LCD_B_V5_VSS);
106 
107  //Set VLCD voltage to 2.60v
108  LCD_B_setVLCDVoltage(LCD_B_BASE, LCD_B_CHARGEPUMP_VOLTAGE_2_60V_OR_2_17VREF);
109  LCD_B_selectChargePumpReference(LCD_B_BASE, LCD_B_INTERNAL_REFERENCE_VOLTAGE);
110 
111  //Enable charge pump and select internal reference for it
112  LCD_B_enableChargePump(LCD_B_BASE);
113 
114  //Disable LCD charge pump during ADC conversion
115  LCD_B_configureChargePump(LCD_B_BASE, LCD_B_CHARGEPUMP_AUTO_DISABLED_DURING_ADC_CONVERSION);
116 
117  //Clear LCD memory
118  LCD_B_clearAllMemory(LCD_B_BASE);
119 
120  //Display "430"
121  LCD_B_setMemory(LCD_B_BASE, LCD_B_MEMORY_BLINKINGMEMORY_0, 0x67);
122  LCD_B_setMemory(LCD_B_BASE, LCD_B_MEMORY_BLINKINGMEMORY_2, 0xF3);
123  LCD_B_setMemory(LCD_B_BASE, LCD_B_MEMORY_BLINKINGMEMORY_4, 0xFC);
124 
125  //Turn LCD on
126  LCD_B_on(LCD_B_BASE);
127 
128  __bis_SR_register(LPM3_bits | GIE);
129 
130  return 0;
131 }
int main(void)